# coding: utf8


def closure_fun():
    x = 1

    def closure(y):
        nonlocal x
        x = x + y
        return x

    return closure


def test_closure_fun():
    f = closure_fun()
    print(
        f"f(10) = {f(10)}\n"
        f"f(10) = {f(10)}"
    )

class closure_class:

    def __init__(self):
        self.x = 1

    def __call__(self, y):
        self.x = self.x + y
        return self.x


def test_closure_class():
    f = closure_class()
    print(
        f"f(10) = {f(10)}\n"
        f"f(10) = {f(10)}"
    )
